<%@codepage="65001"%> 
<!--#include file="../Include/Conn.asp" -->
<!--#include file="seeion.asp"-->
<!--#include file="page.asp" -->
<!--#include file="md5.Asp" -->
<%call chkAdmin("|17") %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" id="css" href="images/style.css">
<title>会员管理</title>
<script language="javascript"> 
<!-- 
function CheckAll(){ 
 for (var i=0;i<eval(form1.elements.length);i++){ 
  var e=form1.elements[i]; 
  if (e.name!="allbox") e.checked=form1.allbox.checked; 
 } 
} 
--> 
</script> 
</head>
<body>
<%if request.querystring("action")="userfl" then%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
   <tr>
    <td height="30" class="topnav"><div>等级管理</div></td>
  </tr>
  </tr>
  <tr>
    <td bgcolor="#EBF2F9">
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="stable">
<%sql="select * from user_fl order by px_id asc" 
dim rs:Set rs=conn.execute(sql,"r1")
if rs.eof then
echo "<div style=""padding:10px;"">暂无分类!</div>"
end if
while not rs.eof%>
<form action="Admin_user.asp?action=userfl&edit=ok" method="post" name="edit">
<tr>
<td width="8%" class="td">ID：<%=rs("Id")%><input name="Id" type="hidden"  size="15"  value="<%=rs("Id")%>"/></td>
<td width="13%" height="25" class="td">等级：<input name="title" class="inp" type="text" size="15"  value="<%=rs("title")%>"/></td>
<td width="58%" class="td">排序：<input name="px_id" type="text" value="<%=rs("px_id")%>" size="5" class="inp"  /></td>
<td width="8%" class="td"><input type="submit" name="button2" id="button2" value="修 改"  class="btn"/>|<input type="button" name="button2" id="button2" value="删 除"  class="btn"/></td>
</tr></form>
<%rs.movenext
wend
rs.close
set rs=nothing%>
      </table>
    </td>
 </tr>
</table>
<div style="margin-top:10px">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<form action="Admin_Channel.asp?action=Channeladd" method="post" name="add">
  <tr>
    <td height="30" class="topnav"><div>增加等级</div></td>
  </tr>
  </tr>
  <tr>
    <td bgcolor="#EBF2F9"><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="stable" >
      <tr>
        <td width="12%" height="25" align="right" class="td">等级名称</td>
        <td width="88%"  class="td"><input name="ChannelName" type="text" size="30" class="btn1"  /></td>
      </tr>
      
      <tr>
        <td width="12%" height="25" align="right" class="td">排序ID</td>
        <td class="td"><input name="OrderID" type="text" value="10" size="30" class="btn1"  /> 
          数字越小越靠前。</td>
      </tr>
      
      <tr>
        <td height="25" align="right" class="td">&nbsp;</td>
        <td class="td"><label>
        <input type="submit" name="button" id="button" value="确定增加"  class="btn"/>
        </label></td>
      </tr>
      
    </table></td>
  </tr></form>
</table>
</div>
<% End If %>
<%if request.querystring("action")="admin" then%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
  <tr>
    <td height="30" class="topnav"><div>会员管理</div> </td>
    <td width="150" class="topnav"><input onClick="location.href='?action=userfl'" type="button" value="会员等级管理" class="btn" > </td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="stable">
<thead><tr>
<td width="30" align="center" class="td"><input name="ID" type="checkbox" /></td>
<td width="60" align="center" class="td">ID</td>
<td width="160" height="25" align="center" class="td">会员帐号</td>
<td width="80" align="center" class="td">会员名字</td>
<td width="80" align="center" class="td">会员等级</td>
<td align="right" class="td">&nbsp;</td>
<td width="80" align="center" class="td">登陆次数</td>
<td width="80" align="center" class="td">是否审核</td>
<td width="160" align="center" class="td">注册时间</td>
<td width="80" align="center" class="td">修改</td>
<td width="80" align="center" class="td">删除</td>
</tr></thead>
<form id="form1" name="form1" method="post" action="?del=checkbox"> 
<%	
set rs=server.createobject("adodb.recordset") 
exec="select * from [user] order by id desc" 
rs.open exec,conn,1,1 
if rs.eof then
response.write ("<div style=""padding:10px;"">暂无会员!</div>")
else
rs.PageSize =30 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if	
for i=1 to rs.pagesize
if rs("sh")=1 then sh="已审核" else sh="<font color=#FF0000>未审核</font>"

%> 
<tr>
<td align="center" class="td"><input name="ID" type="checkbox" id="ID" value="<%=rs("id")%>" /></td>
<td align="center" class="td"><input type="text" class="inp" style="text-align:center; width:40px" value="<%=rs("id")%>" readonly="readonly"/></td>
<td height="25" align="center" class="td"><a href="admin_user.asp?action=xiugai&id=<%=rs("id")%>" style="color:#003399"><%=rs("username")%></a> </td>
<td align="center" class="td"><%=rs("zsname")%></td>
<td align="center" class="td"><%=userkey(rs("key")) %></td>
<td align="right" class="td">&nbsp;</td>
<td align="center" class="td"><%=rs("dlcs")%></td>
<td align="center" class="td"><%=sh%></td>
<td align="center" class="td"><%=rs("data")%></td>
<td align="center" class="td"><input type="button" name="Submit3" value="修改" onclick="window.location.href='admin_user.asp?action=xiugai&id=<%=rs("id")%>' "  class="btn"/></td>
<td align="center" class="td"><input type="button" name="Submit" value="删除" onclick="javascript:if(confirm('确定删除？删除后不可恢复!')){window.location.href='?id=<%=rs("id")%>&amp;del=ok';}else{history.go(0);}"  class="btn"/></td>
</tr>
<%rs.movenext 
if rs.eof then exit for 
next 
end if%>
<tr>
<td align="center" class="td"><input type="checkbox" name="allbox" onclick="CheckAll()" /></td>
<td align="left" class="td">全选</td>
<td height="25" colspan="9" class="td">
<input type="submit" class="btn" onclick="form.action='?sh=ok';" value="批量审核"/>
<input type="submit" class="btn" onclick="form.action='?sh=no';" value="取消审核"/>
<input type="submit" class="btn" onclick="form.action='?del=ok';" value="批量删除"/>
<%call PageControl(iCount,maxpage,page)
rs.close
set rs=nothing%></td>
</tr>
</form>
</table>
</td>
  </tr>
</table>
<%End If %>
<%if request.querystring("action")="xiugai" then
id=request.QueryString("id")
if id="" or not isnumeric(id) then
Response.Write "<script>alert('参数错误！');history.go(-1);</script>" 
Response.End()
end if
exec="select * from [user] where id="& id 
set rs=server.createobject("adodb.recordset") 
rs.open exec,conn,1,1 
if rs.eof and rs.bof then
Response.Write "<script>alert('参数不正确，ID值不存在！');history.go(-1);</script>" 
Response.End()
end if%>
<form  name="add" method="post" action="admin_user.asp?action=xiugai&id=<%=rs("id")%>&xiugai=ok">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td height="30" class="topnav"><div>查看/修改会员资料</div></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="stable" >
      <tr>
        <td width="13%" height="28" align="right" class="td">账号ID</td>
        <td width="87%"  class="td"><%=rs("id")%><input name="id" type="hidden" id="id" value="<%=rs("id")%>" /></td>
      </tr>
      <tr>
        <td width="13%" height="25" align="right" class="td">会员帐号</td>
        <td class="td"><%=rs("username")%></td>
      </tr>
      <tr>
        <td width="13%" height="25" align="right" class="td">会员密码</td>
        <td class="td"><input name="userpassword" type="text" class="inp" size="30"  /> 不修改请留空! </td>
      </tr>
    <tr>
        <td height="25" align="right" class="td">真实姓名</td>
        <td class="td"><%=rs("zsname")%></td>
    </tr>
      <tr>
        <td height="25" align="right" class="td">会员性别</td>
        <td class="td"><label class="inp"><input type="radio" name="sex" value="先生" <%if rs("sex")="先生" then%>checked<%end if%>>先生</label>　 
			<label class="inp"><input type="radio" name="sex" value="女士" <%if rs("sex")="女士" then%>checked<%end if%>>女士</label></td>
      </tr>
    <tr>
    <tr>
    <td align=right class=td>会员等级</td>
    <td class=td >
      <select name="key" class="sel">
		<%set rsc=server.CreateObject("adodb.recordset")
        rsc.open "select * from user_fl order by px_id asc",conn,1,1
		if rsc.eof then
		response.write""
		else
        while not rsc.eof
		if rsc("id")=rs("key") then sel="selected" else sel=""
        response.Write("<option value="""&rsc("id")&""" "&sel&">"&rsc("title")&"</option>")      
        rsc.movenext
        wend
		end if
        rsc.close
        set rsc=nothing%> 
      </select></td>
    </tr>
      <td height="25" align="right" class="td">公司名称</td>
      <td class="td"><label><input name="gsname" type="text" class="inp" value="<%=rs("gsname")%>" size="40" /></label></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">公司地址</td>
      <td class="td"><input name="gsadd" type="text" class="inp" value="<%=rs("gsadd")%>" size="40" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">邮政编码</td>
      <td class="td"><input name="youbian" type="text" class="inp" value="<%=rs("youbian")%>" size="20" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">联系电话</td>
      <td class="td"><input name="tel" type="text" class="inp" value="<%=rs("tel")%>" size="30" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">联系传真</td>
      <td class="td"><input name="fax" type="text" class="inp" value="<%=rs("fax")%>" size="30" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">联系手机</td>
      <td class="td"><input name="sj" type="text" class="inp" value="<%=rs("sj")%>" size="30" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">电子邮箱</td>
      <td class="td"><input name="mail" type="text" class="inp" value="<%=rs("mail")%>" size="30" /></td>
    </tr>
  <tr>
      <td height="25" align="right" class="td">公司网址</td>
      <td class="td"><input name="wz" type="text" class="inp" value="<%=rs("wz")%>" size="30" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">注册时间</td>
      <td class="td"><%=rs("data")%></td>
    </tr>
  <tr>
      <td height="25" align="right" class="td">最后登陆</td>
      <td class="td"><%=rs("dldata")%></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">登陆次数</td>
      <td class="td"><%=rs("dlcs")%> 次</td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">注册IP</td>
      <td class="td"><%=rs("ip")%></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td">&nbsp;</td>
      <td class="td"><input type="submit" name="button" id="button" value="更新资料" class="btn"/></td>
    </tr>
    
    </table>
    </td>
  </tr>
</table></form>
<%end if%>
</body>
</html>
<%'等级修改
if Request.QueryString("edit")="ok" then
Id=request("Id")
sql="Select * from user_fl where Id="&Id
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
IF not isNumeric(request("px_id")) then
Response.Write "<script>alert('排序ID必须为数字！');history.go(-1);</script>" 
end if
rs("title")=request("title")
rs("px_ID")=request("px_ID")
rs.update 
rs.close 
Response.Write "<script>alert('当前等级修改成功！');window.location.href='admin_user.asp?action=userfl';</script>"
end if

if request("userfl")="del" then
set rs=server.createobject("adodb.recordset")
id=Request.QueryString("id")
sql="select * from [user_fl] where id="&id
rs.open sql,conn,2,3
rs.delete
rs.update
Response.Write "<script>alert('删除成功！');window.location.href='admin_user.asp?action=userfl';</script>"
end if

if request("del")="ok" then
set rs=server.createobject("adodb.recordset")
id=Request.QueryString("id")
sql="select * from [user] where id="&id
rs.open sql,conn,2,3
rs.delete
rs.update
Response.Write "<script>alert('删除成功！');window.location.href='admin_user.asp?action=admin';</script>"
end if 


if Request.QueryString("sh")="ok" then
if Request("id")="" then
Response.Write "<script>alert('错误!请选择要操作的记录!');window.location.href='admin_user.asp?action=admin';</script>" 
response.end()
end if
sql="update [user] set sh=1 where id in ("&Request("id")&")" 
conn.execute(sql)
Response.Write "<script>alert('恭喜!审核成功!');window.location.href='admin_user.asp?action=admin';</script>" 
end if
 
if Request.QueryString("sh")="no" then
if Request("id")="" then
Response.Write "<script>alert('错误!请选择要操作的记录!');window.location.href='admin_user.asp?action=admin';</script>" 
response.end()
end if
sql="update [user] set sh=0 where id in ("&Request("id")&")" 
conn.execute(sql) 
Response.Write "<script>alert('恭喜!取消审核成功!');window.location.href='admin_user.asp?action=admin';</script>" 
end if

if Request.QueryString("del")="ok" then
if Request("id")="" then
Response.Write "<script>alert('错误!请选择要操作的记录!');window.location.href='admin_user.asp?action=admin';</script>" 
response.end()
end if
sql="delete from [user] where id in ("&Request("id")&")"
conn.Execute ( sql )
Response.Write "<script>alert('恭喜!操作成功!');window.location.href='admin_user.asp?action=admin';</script>" 
end if

'=====================
if Request.QueryString("xiugai")="ok" then 
id=request("id")
userpassword=request.form("userpassword")
sex=request.form("sex")
key=request.form("key")
gsname=request.form("gsname")
gsadd=request.form("gsadd")
youbian=request.form("youbian")
tel=request.form("tel")
fax=request.form("fax")
sj=request.form("sj")
mail=request.form("mail")
wz=request.form("wz")
	if id="" or not isnumeric(id) then
	Response.Write "<script>alert('参数错误！');history.go(-1);</script>" 
	Response.End()
	end if
	SQL="Select * from [user] where id="&id
	set rs=server.createobject("adodb.recordset")
	rs.open SQL,conn,1,3
	if rs.eof and rs.bof then
Response.Write "<script>alert('参数不正确，ID值不存在！');history.go(-1);</script>" 
	Response.End()
	end if
if request.form("userpassword") <> "" then
rs("userpassword")=md5(request.form("userpassword"))
end if
rs("sex")=sex
rs("gsname")=gsname
rs("gsadd")=gsadd
rs("key")=key
rs("youbian")=youbian
rs("tel")=tel
rs("fax")=fax
rs("sj")=sj
rs("mail")=mail
rs("wz")=wz
rs.update 
rs.close 
response.write "<script>alert('资料修改成功！');window.location.href='admin_user.asp?action=admin';</script>" 
end if%>